/** @jsxImportSource @emotion/react */
import * as React from "react";
import {Text, useTheme,} from "customize-easy-ui-component";
import { ReportViewProps, } from "../../common/base";
import {末尾链接, 落款单位地址,} from "../../common/rarelyVary";
import {检验结论报告,} from "./repView";
import {useSubRepMain} from "../../hook/useSubRepMain";
import {useRepMenuDirItems} from "../../hook/useMainRepUrlOr";
import {AppendixPageVw} from "./AppendixPage";
import {注意事项MVS, 目录页VS, 首页设备概况MVS} from "../rarelyVary";
import {useItemsMapPressure} from "../../common/pressure";
import {ReportFirstPageHeadNmaNmbbm} from "../../contain/rarelyVary";
import {MaterialReviewVw} from "./MaterialReview";
import {AccessoriesVw} from "./Accessories";
import {AddonTestVw} from "./AddonTest";
import {Projects默认} from "./orcBase";


//分项模板还没有做的也不少！
export const ReportView: React.FunctionComponent<ReportViewProps> = ({
    repId,   source: orc,  verId,rep,
}) => {
    const theme= useTheme();
    const [mapFxian]=useItemsMapPressure({ projects:orc.Projects });
    const [renderThickm]= useSubRepMain("cm/thickm", {nestMd:'THICK_MS',orc, repId:repId!, rep, NestMbVer:1});
    const [renderSpectrVs]= useSubRepMain("cm/spectrVs", {nestMd:'SPECTR_VS', orc, repId:repId!, rep, NestMbVer:1});
    const [rootMenu]=useRepMenuDirItems(Projects默认, orc.Projects, `/reportView/${rep?.modeltype}/ver/${verId}/${repId}`);
    const [renderUtrSonic]= useSubRepMain("cm/sonic", {nestMd:'SONIC_TS',orc, repId:repId!, rep, NestMbVer:1});
    const [renderRadioTs ]= useSubRepMain("cm/radio", {nestMd:'RADIO_TS',orc, repId:repId!, rep, NestMbVer:1});
    const [permeation ]= useSubRepMain("cm/permeation", {nestMd:'PERME_TS',orc, repId:repId!, rep, NestMbVer:1});
    const [magnetic ]= useSubRepMain("cm/magnetic", {nestMd:'MAGNT_TS',orc, repId:repId!, rep, NestMbVer:1});
    const [hardness ]= useSubRepMain("cm/hardness", {nestMd:'HARD_TS',orc, repId:repId!, rep, NestMbVer:1});
    const [gasproof ]= useSubRepMain("cm/gasproof", {nestMd:'GASPR_TS',orc, repId:repId!, rep, NestMbVer:1});
  return (
    <React.Fragment>
        {rootMenu}
        <div css={{"@media not print": {marginTop: '1rem', marginBottom: '1rem'}}}>
            <div css={{
                display: 'flex',
                flexDirection: 'column',
                justifyContent: 'space-between',
                "@media print": {height: '100vh', pageBreakInside: 'avoid',}
            }}>
                {ReportFirstPageHeadNmaNmbbm({theme, rep })}
                <div>
                    <Text variant="h3" css={{textAlign: 'center',
                        "@media (min-width:690px),print and (min-width:538px)": {fontSize: theme.fontSizes[6],}
                    }}>
                        移动式压力容器年度检验报告
                    </Text>
                    <br css={{"@media not print": {display: 'none'}}}/>
                    <Text variant="h5" css={{textAlign: 'center',}}> （ FJB/RH 10372-2022 ）</Text>
                </div>
                <div css={{
                    "@media print": {
                        // minHeight: '-webkit-fill-available',
                    }
                }}>
                    {首页设备概况MVS({theme, orc, rep})}
                </div>
                <div css={{
                    textAlign: 'center',
                    "@media print": {
                        // pageBreakAfter: 'always',
                        pageBreakInside: 'avoid'
                    }
                }}>
                    {落款单位地址}
                </div>
            </div>

            {注意事项MVS({
                rep,
                comply: '书为依据《移动式压力容器安全技术监察规程》（TSG R0005）及第1、2、3号修 改单、《压力容器定期检验规则》（TSG R7001）制定，适用于移动式压力容器年度检验报告的结论报告，检验结论仅代表该设备在检验时的安全状况'
            })}

            {目录页VS({theme, orc, rep, suffix: true})}
            {检验结论报告({theme, orc, rep})}
            {MaterialReviewVw({theme, orc, rep})}
            {mapFxian.get('容器年度检验报告附页')?.do &&
                <AppendixPageVw  orc={orc} rep={rep}/>
            }

            {mapFxian.get('壁厚测定报告')?.do && <>
                {renderThickm}
            </>
            }
            {mapFxian.get('壁厚校核报告')?.do && <>
            </>
            }
            {mapFxian.get('射线检测报告')?.do && <>
                {renderRadioTs}
            </>}
            {mapFxian.get('超声波检测报告')?.do && <>
                {renderUtrSonic}
            </>}
            {mapFxian.get('磁粉检测报告')?.do && <>
                {magnetic}
            </>}

            {mapFxian.get('渗透检测报告')?.do && <>
                {permeation}
            </>}
            {mapFxian.get('光谱分析报告')?.do && <>
                {renderSpectrVs}
            </>}

            {mapFxian.get('硬度检测报告')?.do && <>
                {hardness}
            </>}
            {mapFxian.get('金相分析报告')?.do && <>
            </>
            }

            {mapFxian.get('安全附件检验报告')?.do &&
                AccessoriesVw({theme, orc, rep})
            }
            {/*安全阀校验  可能算单独的？ */}
            {mapFxian.get('安全阀校验报告')?.do && <>
            </>
            }
            {mapFxian.get('耐压试验报告')?.do && <>
            </>
            }

            {mapFxian.get('气密性试验报告')?.do && <>
                {gasproof}
            </>}
            {mapFxian.get('附加检验报告')?.do &&
                AddonTestVw({theme, orc, rep})
            }
        </div>

        {末尾链接({template: rep?.modeltype, verId, repId: repId || ''})}
    </React.Fragment>
  );
}
